2015-09-04.txt 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainPhotographed')
  2. BEGIN
  3. DROP VIEW [dbo].BView_CameraControlBookMainPhotographed
  4. END
  5. GO
  6. IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainPhotographed]'))
  7. EXEC dbo.sp_executesql @statement = N'
  8. CREATE VIEW [dbo].[BView_CameraControlBookMainPhotographed]
  9. AS
  10. SELECT tb_ErpOrder.ID,
  11. dbo.tb_ErpOrder.Ord_DividedShop,
  12. Ord_Type,
  13. dbo.tb_ErpOrdersPhotography.ID AS VID,
  14. dbo.tb_ErpOrder.Ord_Number,
  15. dbo.tb_ErpOrderDigital.Ordv_ViceNumber,
  16. Ordv_DigitalNumber,
  17. CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
  18. dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
  19. Cus_Name AS 客户姓名,
  20. Cus_Sex_cs AS 客户性别,
  21. Cus_Telephone AS 客户电话,
  22. dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.fn_ConvertDate(GregorianCalendar_DayForMarriage))) AS 婚期,
  23. (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
  24. (Ord_SeriesPrice - (Case when (select sum(Pay_AmountOf) from dbo.tb_ErpPayment where Pay_OrdNumber =Ord_Number and Pay_Category in (''全款'',''后期收款'',''预约收款'',''预约补款'')) is null then 0 else (select sum(Pay_AmountOf) from dbo.tb_ErpPayment where Pay_OrdNumber =Ord_Number and Pay_Category in (''全款'',''后期收款'',''预约收款'',''预约补款'')) end) + (Select sum(Plu_Amount) as Plu_Amount from tb_ErpPlusPickItems where Plu_OrdNumber = Ord_Number)) AS 欠款,
  25. dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
  26. dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
  27. dbo.tb_ErpOrdersPhotography.Ordpg_Sights AS 拍摄名称,
  28. dbo.fn_CheckPhotographyStatus(Ordpg_PhotographyStatus) AS 拍摄状态,
  29. dbo.fn_CheckDateTime(Ordpg_ReservationPhotographyTime) AS 摄影时间,
  30. Ordpg_ReservationPhotographyTime AS 摄影时间查询,
  31. dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyName) AS 摄影师,
  32. dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationPhotographyAssistant) AS 摄影助理,
  33. dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationMakeupArtist) AS 化妆师,
  34. dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationMakeupAssistant) AS 化妆助理,
  35. dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_ReservationBootDivision) AS 引导师,
  36. dbo.tb_ErpOrdersPhotography.Ordpg_Remark AS 录入备注,
  37. dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpOrdersPhotography.Ordpg_Dispatcher) AS 安排人,
  38. dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.tb_ErpOrdersPhotography.Ordpg_DispatchTime)) AS 安排时间,
  39. (SELECT COUNT(tb_ErpOrdersPhotography_1.Ordpg_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrdersPhotography AS tb_ErpOrdersPhotography_1 LEFT OUTER JOIN
  40. dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1 ON tb_ErpOrdersPhotography_1.Ordpg_ViceNumber = tb_ErpOrderDigital_1.Ordv_ViceNumber WHERE (tb_ErpOrderDigital_1.Ordv_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
  41. FROM dbo.tb_ErpOrder LEFT OUTER JOIN
  42. dbo.tb_ErpOrderDigital ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpOrderDigital.Ordv_Number LEFT OUTER JOIN
  43. dbo.tb_ErpOrdersPhotography ON
  44. dbo.tb_ErpOrderDigital.Ordv_ViceNumber = dbo.tb_ErpOrdersPhotography.Ordpg_ViceNumber
  45. left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
  46. WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'') AND (dbo.tb_ErpOrder.Ord_Type IN (''0'', ''1'', ''2''))
  47. '
  48. GO
  49. IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainSelectDress')
  50. BEGIN
  51. DROP VIEW [dbo].BView_CameraControlBookMainSelectDress
  52. END
  53. GO
  54. IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainSelectDress]'))
  55. EXEC dbo.sp_executesql @statement = N'
  56. CREATE VIEW [dbo].[BView_CameraControlBookMainSelectDress]
  57. AS
  58. SELECT
  59. tb_ErpOrder.ID,
  60. Ord_DividedShop,
  61. Ord_Type,
  62. Ord_Number,
  63. Ordv_ViceNumber,
  64. Ordv_DigitalNumber,
  65. CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
  66. dbo.fn_CheckOrderType(Ord_Type) AS 订单类型,
  67. Cus_Name AS 客户姓名,
  68. Cus_Sex_cs AS 客户性别,
  69. Cus_Telephone AS 客户电话,
  70. dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.fn_ConvertDate(GregorianCalendar_DayForMarriage))) AS 婚期,
  71. (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
  72. dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
  73. dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
  74. (case when Ord_Type = ''1'' then (select Ordpg_Sights from tb_ErpOrdersPhotography where Ordpg_ViceNumber = Ordv_ViceNumber) else '''' end) as 拍摄名称,
  75. dbo.fn_CheckOrderClothingStatus(Ordv_ClothingStatus) AS 选礼服状态,
  76. dbo.fn_CheckUserIDGetUserName(Ordv_ReservationClothingName) AS 选礼服师,
  77. dbo.fn_CheckDateTime(Ordv_ReservationClothingTime) AS 选礼服时间,
  78. Ordv_ReservationClothingTime AS 选礼服时间查询,
  79. dbo.fn_CheckUserIDGetUserName(Ordv_ClothingDispatcher) AS 安排人,
  80. dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(Ordv_ClothingDispatchTime)) AS 安排时间,
  81. (SELECT COUNT(Ordv_ViceNumber) AS Expr1 FROM dbo.tb_ErpOrderDigital AS tb_ErpOrderDigital_1 WHERE (Ordv_Number = Ord_Number)) AS Ord_ViceOrderCount
  82. FROM dbo.tb_ErpOrder LEFT OUTER JOIN
  83. dbo.tb_ErpOrderDigital ON Ord_Number = Ordv_Number
  84. left join tempTB_AggregationCustomer on Ord_Number = GP_OrderNumber
  85. WHERE (Ord_Class = ''1'') AND (Ord_Type IN (''0'', ''1'', ''2''))
  86. '
  87. GO
  88. IF EXISTS (SELECT TABLE_NAME FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_NAME = N'BView_CameraControlBookMainWedding')
  89. BEGIN
  90. DROP VIEW [dbo].BView_CameraControlBookMainWedding
  91. END
  92. GO
  93. IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[BView_CameraControlBookMainWedding]'))
  94. EXEC dbo.sp_executesql @statement = N'
  95. CREATE VIEW [dbo].[BView_CameraControlBookMainWedding]
  96. AS
  97. SELECT
  98. tb_ErpOrder.ID,
  99. dbo.tb_ErpOrder.Ord_DividedShop, Ord_Type,
  100. dbo.tb_ErpWeddingService.Ws_Type,
  101. dbo.tb_ErpWeddingService.ID AS VID,
  102. dbo.tb_ErpOrder.Ord_Number,
  103. 0 AS Ordv_DigitalNumber,
  104. CASE [Ord_SinceOrderNumber] WHEN '''' THEN Ord_Number ELSE Ord_SinceOrderNumber END AS 订单号,
  105. dbo.fn_CheckOrderType(dbo.tb_ErpOrder.Ord_Type) AS 订单类型,
  106. Cus_Name AS 客户姓名,
  107. Cus_Sex_cs AS 客户性别,
  108. Cus_Telephone AS 客户电话,
  109. dbo.fn_CheckDateTimeReturn_Date(dbo.fn_CheckDateTime(dbo.fn_ConvertDate(GregorianCalendar_DayForMarriage))) AS 婚期,
  110. (select stuff((select '','' + dbo.fn_CheckUserIDGetUserName( OrdPe_OrdersPerson) from tb_ErpOrdersPerson where OrdPe_OrderNumber=Ord_Number for xml path('''')),1,1,'''')) as 接单人,
  111. dbo.tb_ErpOrder.Ord_SeriesName AS 套系名称,
  112. dbo.tb_ErpOrder.Ord_SeriesPrice AS 套系价格,
  113. dbo.tb_ErpWeddingService.Ws_ProdName AS 服务内容,
  114. dbo.fn_CheckWeddingServiceStatus(dbo.tb_ErpWeddingService.Ws_Status) AS 服务状态,
  115. dbo.fn_CheckDateTime(Ws_WeddingDate) AS 服务日期,
  116. Ws_WeddingDate AS 服务日期查询,
  117. dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpWeddingService.Ws_Serviceman1) AS 服务人员1,
  118. dbo.fn_CheckUserIDGetUserName(dbo.tb_ErpWeddingService.Ws_Serviceman2) AS 服务人员2,
  119. dbo.tb_ErpWeddingService.Ws_Remark AS 服务备注,
  120. (SELECT COUNT(Ws_Number) AS Expr1 FROM dbo.tb_ErpWeddingService AS tb_ErpWeddingService_1 WHERE (Ws_Number = dbo.tb_ErpOrder.Ord_Number)) AS Ord_ViceOrderCount
  121. FROM dbo.tb_ErpOrder LEFT OUTER JOIN dbo.tb_ErpWeddingService ON dbo.tb_ErpOrder.Ord_Number = dbo.tb_ErpWeddingService.Ws_Number
  122. left join tempTB_AggregationCustomer on tb_ErpOrder.Ord_Number = GP_OrderNumber
  123. WHERE (dbo.tb_ErpOrder.Ord_Class = ''1'')
  124. '
  125. GO